﻿using Abp.AutoMapper;
using Abp.Runtime.Validation;
using Abp.Timing;
using AVIS.OutBound.Orders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AVIS.OutBound.BookOrders.Dto
{
    /// <summary>
    /// 按门店预订的请求参数，在线预订流程的第一步
    /// </summary>
    [AutoMapTo(typeof(BookOrder))]
    public class SubmitStoreInput : ICustomValidate
    {
        /// <summary>
        /// 订单Id，修改订单时需传入
        /// </summary>
        public string OrderId { get; set; }

        /// <summary>
        /// 取车时间
        /// </summary>
        [Required]
        public DateTime PickupDateTime { get; set; }

        /// <summary>
        /// 取车门店编号
        /// </summary>
        [Required]
        public string PickupStoreCode { get; set; }

        /// <summary>
        /// 取车城市编号
        /// </summary>
        [Required]
        public string PickUpCityCode { get; set; }

        /// <summary>
        /// 取车的区域编号
        /// </summary>
        [Required]
        public string PickUpRegionCode { get; set; }

        /// <summary>
        /// 还车时间
        /// </summary>
        [Required]
        public DateTime ReturnDateTime { get; set; }

        /// <summary>
        /// 还车门店编号
        /// </summary>
        [Required]
        public string ReturnStoreCode { get; set; }

        /// <summary>
        /// 还车城市编号
        /// </summary>
        [Required]
        public string ReturnCityCode { get; set; }

        /// <summary>
        /// 还车的区域编号
        /// </summary>
        [Required]
        public string ReturnRegionCode { get; set; }

        /// <summary>
        /// AWD号
        /// </summary>
        public string AWD { get; set; }

        /// <summary>
        /// 优惠券号
        /// </summary>
        public string CouponNum { get; set; }

        /// <summary>
        /// 会员卡号
        /// </summary>
        public string WizardNum { get; set; }

        /// <summary>
        /// 协议号
        /// </summary>
        public string IATA { get; set; }

        /// <summary>
        /// 协议号类型
        /// </summary>
        public int IATAType { get; set; }

        public void AddValidationErrors(CustomValidationContext context)
        {
            if (PickupDateTime <= Clock.Now)
            {
                context.Results.Add(new ValidationResult("无效的取车时间"));
            }

            if (ReturnDateTime <= Clock.Now)
            {
                context.Results.Add(new ValidationResult("无效的还车时间"));
            }
        }
    }
}
